#include "bsp_wdg.h"

/**
  * @brief  initialize led function
  * @param  none
  * @retval none
  */
void at32_wdg_init(void)
{
	/* disable register write protection */
	wdt_register_write_enable(TRUE);

	/* set the wdt divider value */
	wdt_divider_set(WDT_CLK_DIV_4);

	/* set reload value

	timeout = reload_value * (divider / lick_freq )    (s)

	lick_freq    = 40000 Hz
	divider      = 4
	reload_value = 3000

	timeout = 3000 * (4 / 40000 ) = 0.3s = 300ms
	*/
	wdt_reload_value_set(3000 - 1);

	/* reload wdt counter */
	wdt_counter_reload();

	/* enable wdt */
	wdt_enable();
}

/**
  * @brief  reload the wdg
  * @param  none
  * @retval none
  */
void reload_wdg(void)
{
	wdt_counter_reload();
}


